{extend name="layout:base" /}{block name="content"}

<?php
$global=isSupperManagerForSession();
?>
<link rel="stylesheet" type="text/css" href="/static/My97DatePicker/skin/WdatePicker.css" />
<script charset="utf-8" src="/static/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
    .yg_inp>input{margin-bottom: 10px;}
    #zc_detail table{margin:10px;}
    #zc_detail table tr td{border: 1px solid #ddd;height:40px;line-height:40px;padding-left:5px;padding-right:5px;}
    .ordertable input {width:90%;}
    .policeLable{padding:2px 4px;margin-left:4px;}
    #taskDate .taskDateItem{width:100%;height:40px;line-height:40px;margin:4px 0px;}
    #taskDate .taskDateItem .taskDateItemLeft{width:10%;float:left;}
    #taskDate .taskDateItem .taskDateItemRight1{width:70%;float:left;border:1px solid #139667;height: 42px;}
    #taskDate .taskDateItem .taskDateItemRight2{width:20%;float:right;}
    #taskDate .taskDateItem .opUsers img{width:22px;margin-left:5px;}
    #taskDate .taskDateItem .itemUser{padding: 4px 6px;background:#139667;margin-left:4px;color:white;}
    #taskDate .taskDateItem .clear{clear:both;width:0px;height:0px;overflow:hidden;}
    #taskDate .taskDateItem .jia,#taskDate .taskDateItem .jian{font-size:30px;cursor:pointer;font-weight:800;margin-left:5px;}
</style>

<!--引入JS-->
<script type="text/javascript" src="/static/admin/js/ajaxfileupload.js?t=1"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>

<section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
        <span data-url="/admin/pushmsg/lists" onclick="ContentLoadGo('/admin/pushmsg/lists')">推送管理</span>
         >
         <span data-url="/admin/pushmsg/addData"  onclick="ContentLoadGo('/admin/pushmsg/addData')"  >添加</span>
         </div>
</section>
<section id="zc_detail">
<table class="ordertable" style="width:100%;" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <td width="120"><div align="right">功能类型</div></td>
       <td class="tr_cons">
           <select id="optype" class="select" name="data[optype]">
               <?php
               foreach($funLists as $key=>$val)
               {

               ?>
               <option value="<?php echo $key; ?>" ><?php echo $val; ?></option>
               <?php
                }
                ?>
           </select>
       </td>
     </tr>


    <tr class="funvalTr">
        <td width="120"><div align="right">功能类型</div></td>
        <td class="tr_cons">
            <select name="data[fun]" id="fun" class="select">

                <option value="0">无</option>
                <option value="1" <?php if($info['fun']==1){echo 'selected';} ?>>跳转商品</option>
                <option value="2" <?php if($info['fun']==2){echo 'selected';} ?>>跳转话题</option>
                <option value="3" <?php if($info['fun']==3){echo 'selected';} ?>>跳转想法</option>
                <option value="4" <?php if($info['fun']==4){echo 'selected';} ?>>跳转梦话</option>
                <option value="5" <?php if($info['fun']==5){echo 'selected';} ?>>跳转挑战</option>
                <option value="6" <?php if($info['fun']==6){echo 'selected';} ?>>跳转消息</option>
                <option value="7" <?php if($info['fun']==7){echo 'selected';} ?>>跳转订单</option>
                <option value="8" <?php if($info['fun']==8){echo 'selected';} ?>>跳转我的</option>

            </select>
        </td>
    </tr>
    <tr>
        <td width="120"><div align="right">值</div></td>
        <td class="tr_cons">
            <input type="text" name="data[val]" id="val" value="<?php echo $info['val']; ?>" placeholder="" class="textbox" style="padding:0px;width:100px;" />
        </td>
    </tr>
    <tr>
        <td width="120"><div align="right">标题</div></td>
        <td class="tr_cons">
            <input type="text" name="data[title]" id="title" value="<?php echo $info['title']; ?>" placeholder="" class="textbox" style="padding:0px;" />
        </td>
    </tr>


    <tr>
        <td><div align="right">内容</div></td>
        <td colspan="7">
            <textarea name="data[cont]" id="cont" cols="60" rows="2" style="margin-top:2px;"><?php echo $info['cont']; ?></textarea>
            <div style="font-size:14px;color:red;">提示：不能够超过200个字</div>
        </td>
    </tr>



    <tr>
        <td width="120"><div align="right">推送用户</div></td>
        <td class="tr_cons">
            <select name="scop" id="scop" class="select">
                <option value="0">全部</option>
                <option value="1">普通用户</option>
                <option value="2">VIP用户</option>
                <option value="3">单个用户</option>
            </select></td>
    </tr>
    <tr id="uname_tr">
        <td width="120"><div align="right">账号</div></td>
        <td class="tr_cons">
            <input type="text" name="uname" id="uname" value="" placeholder="" class="textbox" style="padding:0px;width:100px;" />
        </td>
    </tr>

    <tr>
        <td width="120"><div align="right">推送类型</div></td>
        <td class="tr_cons">
            <select name="push_time_type" id="push_time_type" class="select">
                <option value="0">立即推送</option>
                <option value="1">定时推送</option>
                <option value="2">每日循环推送</option>
            </select></td>
    </tr>

    <tr id="ds_push_time_tr1">
        <td width="120"><div align="right">推送时间</div></td>
        <td class="tr_cons">
            <input name="ds_push_time1"  id="ds_push_time1" class="Wdate textbox" placeholder="推送时间"
                   onfocus="WdatePicker({lang:'zh-cn',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" value="" size="12"  type="text" style="padding: 0 5px;font-size: 12px;border: 1px #139667 solid;vertical-align: middle;width:150px;" >
        </td>
    </tr>

    <tr id="ds_push_time_tr2">
        <td width="120"><div align="right">推送时间</div></td>
        <td class="tr_cons">
            <select name="ds_push_time2" id="ds_push_time2" class="select">
                <?php
                    for($i=0;$i<24;$i++)
                    {
                        for($j=0;$j<2;$j++)
                        {
                            $stringTime1="";
                            $stringTime2="";
                            if($j==0)
                            {
                                $stringTime2="00";
                            }
                            else
                            {
                                $stringTime2 ="30";
                            }
                            if($i<10)
                            {
                                $stringTime1 = "0".$i;
                            }
                            else
                            {
                                $stringTime1 = $i;
                            }
                            $stringTime = $stringTime1 .":".$stringTime2;

                        ?>
                        <option value="<?php echo $stringTime; ?>"><?php echo $stringTime; ?></option>
                        <?php
                        }
                    }
                ?>
            </select></td>
        </td>
    </tr>
     <tr>
       <td style="height:50px;text-align:center;" colspan="2">
			<input type="button" power="70000"  style="width:80px;margin-top:4px;margin-bottom:4px;padding:0px;" value="添加" class="link_btn add"/>
       </td>
     </tr>
   </table>
</section>


<script type="text/javascript">

function myResearch(){
   var url="/admin/pushmsg/addData";
   var param={
   };
   ContentGet(url,param);
}
    
      
$(function(){
    var gnum=0;
    var lastObj;


    $(".funvalTr").hide();
    $("#optype").change(function(){
        var v =$(this).val();
        if(v==2)
        {
            $(".funvalTr").show();
        }else
        {
            $(".funvalTr").hide();
        }
    });
    //设置搜索栏
    $(".research").click(function(){
       var page =$(this).attr("page");
       $("#cpage").val(page);
       myResearch();
    });
    $('#uname_tr').hide();
    $('#ds_push_time_tr1').hide();
    $('#ds_push_time_tr2').hide();
    $("#scop").change(function(){
        var t=$(this).val();

        if(t=='3')
        {
            $('#uname_tr').show();
        }
        else
        {
            $('#uname_tr').hide();
        }
    });
    $("#push_time_type").change(function(){
        var t=$(this).val();

        if(t=='1')
        {
            $('#ds_push_time_tr1').show();
            $('#ds_push_time_tr2').hide();
        }
        else if(t=='2')
        {
            $('#ds_push_time_tr1').hide();
            $('#ds_push_time_tr2').show();
        }
        else
        {
            $('#ds_push_time_tr1').hide();
            $('#ds_push_time_tr2').hide();
        }
    });



    $(".add").unbind().bind("click",function(){

        var that =this;
        var url="/admin/pushmsg/addData";
        var generaData=$("[name^='data']");
        var fun=$("#fun").val();
        var title=$("#title").val();
        var cont=$("#cont").val();
        var scop=$("#scop").val();
        var uname=$("#uname").val();
        var push_time_type=$("#push_time_type").val();
        var ds_push_time1=$("#ds_push_time1").val();
        var ds_push_time2=$("#ds_push_time2").val();
        if(title=="") {
            ErrTiShi("标题不能够为空");return false;
        }
        if(cont=="") {
            ErrTiShi("内容不能为空");return false;
        }
        // if(fun=="") {
        //     ErrTiShi("功能类型不能为空");return false;
        // }
        if(scop==3)//判断推送指定用户时，需要填写指定用户的账号
        {
            if(uname=="")
            {
                ErrTiShi("推送账号不能够为空");return false;
            }
        }
        var param={
                data:{},
                scop:scop,
                uname:uname,

                push_time_type:push_time_type,
                ds_push_time1:ds_push_time1,
                ds_push_time2:ds_push_time2,
                sys_opt:'addData'//后台判断编辑操作
        };
        getFormData(generaData,param.data);

        AjaxRequest(url,param,function(data){
            if(data.err==0) {
                SuccessTiShi("操作成功");
                ContentLoadGo("/admin/pushmsg/lists");
            } else
            {
                ErrTiShi(data.msg);
            }
        });
    });

    //导航
    $(".topBannerItem").click(function(){
       var attArr = $(this).attr();
       goToSelfLink(attArr);
    });
});
</script>
{/block}